import React from "react";
import { useNavigate } from "react-router-dom";

export default function Header() {
    const navigate = useNavigate();

    const goBack = () => {
        navigate(-1);
    };

    const goForward = () => {
        navigate(1);
    };

    return (
        <div className="page-header">
            <h2>React Router Demo</h2>
            <button onClick={goBack}>←后退</button>
            <button onClick={goForward}>前进→</button>
        </div>
    );
}
